package cn.ittaoli.movie.service;

import cn.ittaoli.movie.dao.AdminMapper;
import cn.ittaoli.movie.dao.AdminMapperCustomer;
import cn.ittaoli.movie.model.Admin;
import cn.ittaoli.utils.MD5;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by lub_lenovo on 2017/11/1.
 */
@Service
public class AdminService {
    @Autowired
    private AdminMapper adminMapper;

    @Autowired
    private AdminMapperCustomer adminMapperCustomer;

    public Admin findOne(int i) {
        return adminMapper.selectByPrimaryKey(i);
    }

    public int add(Admin admin) {

        admin.setInserttime(System.currentTimeMillis());
        admin.setLastupdatetime(System.currentTimeMillis());
        admin.setPassword(MD5.getMD5("ittaoli"+admin.getPassword()+"com2017"));
        return adminMapper.insert(admin);
    }

    public List<Admin> getList() {
        List<Admin> admins=adminMapperCustomer.getList();
        return admins;
    }
}
